@SuppressWarnings("unchecked")
public class p1015_1375ms {

	public static//
	// -----
	// -----
	class Main {
		public static void main(String[] args) throws Exception {
			java.io.BufferedReader reader = new java.io.BufferedReader(new java.io.InputStreamReader(System.in));
			int id = 0;
			while (true) {
				String line = reader.readLine();
				if (line.isEmpty())
					continue;
				if (line.startsWith("0 0"))
					break;
				String[] parts = line.split(" ");
				int n = Integer.parseInt(parts[0]);
				int m = Integer.parseInt(parts[1]);
				int[][] input = read(reader, n);
				int[] juries = process(n, m, input);
				System.gc();

				int sump = 0, sumd = 0;
				for (int i : juries) {
					sump += input[i][0];
					sumd += input[i][1];
				}

				System.out.print("Jury #" + (++id) + "\nBest jury has value " + sump + " for prosecution and value "
						+ sumd + " for defence:\n");
				for (int i : juries)
					System.out.print(" " + (i + 1));
				System.out.print("\n\n");
			}
		}

		static int[][] read(java.io.BufferedReader reader, int n) throws Exception {
			int[][] input = new int[n][];
			for (int i = 0; i < n; i++) {
				String[] parts1 = reader.readLine().trim().split("\\s+");
				int pi = Integer.parseInt(parts1[0]);
				int di = Integer.parseInt(parts1[1]);
				input[i] = new int[] { pi, di, pi - di, pi + di };
			}
			return input;
		}

		static int[] process(int n, int m, int[][] input) {
			// data: for m in n, each dif -> max sum
			java.util.Map<Integer, Integer>[][] data = new java.util.Map[n + 1][];
			java.util.Set<Integer>[][] flag = new java.util.Set[n + 1][];
			for (int i = 0; i <= n; i++) {
				data[i] = new java.util.Map[m + 1];
				flag[i] = new java.util.Set[m + 1];
				for (int j = 0; j <= m; j++) {
					data[i][j] = new java.util.HashMap<Integer, Integer>();
					flag[i][j] = new java.util.HashSet<Integer>();
				}
				data[i][0].put(0, 0);
			}

			// dp
			for (int i = 1; i <= n; i++) {
				for (int j = 1; j <= m; j++) {
					java.util.Map<Integer, Integer> cell = data[i][j];
					cell.putAll(data[i - 1][j]);
					for (java.util.Map.Entry<Integer, Integer> entry : data[i - 1][j - 1].entrySet()) {
						int dif = input[i - 1][2] + entry.getKey();
						int sum = input[i - 1][3] + entry.getValue();
						if (!cell.containsKey(dif) || sum > cell.get(dif)) {
							cell.put(dif, sum);
							flag[i][j].add(dif);
						}
					}
				}
			}

			// find final answer
			int dif = 0, abs = Integer.MAX_VALUE, sum = -1;
			for (java.util.Map.Entry<Integer, Integer> entry : data[n][m].entrySet()) {
				int curDIf = entry.getKey();
				int curAbs = Math.abs(curDIf);
				if (abs > curAbs) {
					dif = curDIf;
					abs = curAbs;
					sum = entry.getValue();
				} else if (abs == curAbs && entry.getValue() > sum) {
					dif = curDIf;
					sum = entry.getValue();
				}
			}

			// output
			int[] juries = new int[m];
			int j = m;
			for (int i = n; i > 0; i--) {
				if (flag[i][j].contains(dif)) {
					juries[--j] = i - 1;
					dif -= input[i - 1][2];
				}
			}
			return juries;
		}
	}

	// -----
	// -----

	public static void main(String[] args) throws Exception {
		Judge.run();
	}

}
